home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 1.8 KB | 101 lines | [TEXT/CWIE] |
- //
- // It's an unfortunately little-known fact that 'cicn's can be many
- // sizes, and not only that, but that any size 'cicn' can be put into
- // a menu item. It's probably not good HI to put in 'cicn's of sizes
- // other than 32x32 or 16x16; happily, this covers the sizes developers
- // want most.
- //
- // Complaints and kudos to:
- //
- // Pete Gontier
- // Apple Macintosh Developer Technical Support
- // <gurgle@apple.com>
- //
-
- #define OLDROUTINELOCATIONS 0
- #define OLDROUTINENAMES 0
- #define SystemSevenOrLater 1
-
- #ifndef __FONTS__
- # include <Fonts.h>
- #endif
-
- #ifndef __DIALOGS__
- # include <Dialogs.h>
- #endif
-
- #ifndef __RESOURCES__
- # include <Resources.h>
- #endif
-
- static Boolean gQuitting;
-
- static pascal OSErr InitMac (void)
- {
- MaxApplZone ( );
- InitGraf (&(qd.thePort));
- InitFonts ( );
- InitWindows ( );
- InitMenus ( );
- TEInit ( );
- InitDialogs (nil);
-
- return noErr;
- }
-
- static pascal void Command (long ms)
- {
- short menuID = ms >> 16,
- menuItem = ms;
-
- if (menuID == 129)
- {
- gQuitting = true;
- }
- }
-
- static pascal void HandleEvent (const EventRecord *eventP)
- {
- if (eventP->what == mouseDown)
- {
- WindowRef whichWindow;
- short partCode = FindWindow (eventP->where, &whichWindow);
- if (partCode == inMenuBar)
- {
- long ms = MenuSelect (eventP->where);
- if (ms) Command (ms);
- HiliteMenu (0);
- }
- }
- }
-
- static pascal Boolean SetUpMenuBar (void)
- {
- Boolean result = false;
- Handle mBar = GetNewMBar (128);
- if (!ResError ( ) && mBar)
- {
- SetMenuBar (mBar);
- AppendResMenu (GetMenuHandle (130), 'DRVR');
- DrawMenuBar ( );
- result = true;
- ReleaseResource (mBar);
- }
- return result;
- }
-
- void main (void)
- {
- if (!InitMac ( ) && SetUpMenuBar ( ))
- {
- do
- {
- EventRecord event;
- InitCursor ( );
- WaitNextEvent (everyEvent, &event, -1, nil);
- HandleEvent (&event);
- }
- while (!gQuitting);
- }
- }
-